package com.asiainfo.complier.conf;

import com.asiainfo.complier.helper.FileHelper;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class ConfManager {

	public static void write2Conf(ArrayList<String> fileList) {
		String path = System.getProperty("user.home") + "\\fileconf.properties";
		String content = "";
		for (String s : fileList) {
			content += s + "\n";
		}
		FileHelper.write2File(path, content);
	}

	/**
	 * @return
	 */
	public static ArrayList<String> getConfFile() {
		ArrayList<String> lst = new ArrayList<String>();
		String path = System.getProperty("user.home") + "\\fileconf.properties";
		StringBuffer sbBuffer = new StringBuffer();
		FileReader reader = null;
		try {
			reader = new FileReader(path);

			BufferedReader bufferedReader = new BufferedReader(reader);
			String line;

			while ((line = bufferedReader.readLine()) != null) {
				sbBuffer.append(line + "\n");
				lst.add(line);
			}
			bufferedReader.close();
			reader.close();
		} catch (Exception e) {

			e.printStackTrace();
		}
		return lst;
	}

	private ConfManager() {
	}
}
